package com.panfeng.xcloud.scheduler.service;

import com.alibaba.fastjson.JSONObject;
import com.binance.client.model.enums.CandlestickInterval;
import com.panfeng.xcloud.boss.provider.dto.request.OperateBotReqDTO;
import com.panfeng.xcloud.boss.provider.dto.request.QuantBotDetailDTO;
import com.panfeng.xcloud.common.core.web.vo.InnerTransferVO;
import com.panfeng.xcloud.common.core.web.vo.OrderDetailResponseVO;
import com.panfeng.xcloud.common.core.web.vo.TradeResponseVO;

import java.math.BigDecimal;

public interface IFeignService {

    /**
     * 发送邮件
     *
     * @param message
     * @return
     */
    void sendEmail(String message);

    /**
     * 同步Assets服务的字典表对象
     *
     * @return
     */
    void syncAssetsDataDictionary();

    /**
     * 同步Member服务的字典表对象
     *
     * @return
     */
    void syncMemberDataDictionary();

    /**
     * 走交易流程
     *
     * @param operateBotReqDTO
     * @param systemInnerType
     * @return
     */
    TradeResponseVO chooseSendOrderHttp(OperateBotReqDTO operateBotReqDTO, Integer systemInnerType) throws Exception;

    /**
     * 根据交易所获取真实下单数量
     *
     * @param operateBotReqDTO
     * @param amount
     * @return
     */
    BigDecimal toSetOpenOrderAmount(OperateBotReqDTO operateBotReqDTO, BigDecimal amount) throws Exception;

    /**
     * 查询账户总可用余额
     *
     * @param exchangeType
     * @param userId
     * @param valuationAsset
     * @return
     */
    BigDecimal getTotalAvaliableMoney(Integer exchangeType, String userId, String valuationAsset) throws Exception;

    /**
     * 查询某交易对保证金率
     *
     * @param exchangeType
     * @param userId
     * @param contractCode
     * @param direction
     * @return
     */
    BigDecimal getRiskRate(Integer exchangeType, String userId, String contractCode, String direction) throws Exception;

    /**
     * 查询某交易对的可用仓位
     *
     * @param exchangeType
     * @param userId
     * @param contractCode
     * @param direction
     * @param leverRate
     * @return
     */
    BigDecimal getAvaliablePosition(Integer exchangeType, String userId, String contractCode, String direction, Integer leverRate) throws Exception;

    /**
     * 查询某交易对的可用余额
     *
     * @param exchangeType
     * @param userId
     * @param contractCode
     * @return
     */
    BigDecimal getAvaliableMoney(Integer exchangeType, String userId, String contractCode) throws Exception;

    /**
     * 查询某交易对的可开张数
     *
     * @param exchangeType
     * @param operateBotReqDTO
     * @return
     */
    BigDecimal getAvaliablePieces(Integer exchangeType, OperateBotReqDTO operateBotReqDTO) throws Exception;

    /**
     * 交易所下市价单
     *
     * @param exchangeType
     * @param operateBotReqDTO
     * @param quantBotDetailDTO
     * @return
     */
    TradeResponseVO trade(Integer exchangeType, OperateBotReqDTO operateBotReqDTO, QuantBotDetailDTO quantBotDetailDTO) throws Exception;

    /**
     * 获取订单详情
     *
     * @param exchangeType
     * @param operateBotReqDTO
     * @param tradeResponseVO
     * @return
     */
    OrderDetailResponseVO getOrderDetail(Integer exchangeType, OperateBotReqDTO operateBotReqDTO, TradeResponseVO tradeResponseVO) throws Exception;

    /**
     * 同账户内资金划转
     *
     * @param innerTransferVO
     * @return
     */
    String transferInner(InnerTransferVO innerTransferVO) throws Exception;

    /**
     * 获取展示市价
     *
     * @param exchangeType
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @return
     */
    BigDecimal getAppearMarketPrice(Integer exchangeType, String userId, String destinationCoin, String sourceCoin) throws Exception;

    /**
     * 获取行情深度,供计算使用
     *
     * @param exchangeType
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @return
     */
    JSONObject getMarketPriceDepth(Integer exchangeType, String userId, String destinationCoin, String sourceCoin) throws Exception;

    /**
     * 获取K线数据,供计算使用
     *
     * @param exchangeType
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @param interval
     * @param startTime
     * @param endTime
     * @param limit
     * @return
     */
    JSONObject getCandleStick(Integer exchangeType, String userId, String destinationCoin, String sourceCoin, CandlestickInterval interval, Long startTime, Long endTime, int limit) throws Exception;
}
